<template>
	<view class="card refund-rule">
		<view class="card-title">费用说明</view>
		<view class="tourist-refund">
			<view class="table">
				<view class="table-header">
					<view class="col-2">费用包含</view>
				</view>
				<view class="table-tr" v-for="(item, index) in tourist_include_fee_rules" :key="index">
					<view class="first-td">{{ item.sub_type_name }}</view>
					<view class="second-td">{{ format(item.display_items) }}</view>
				</view>
			</view>
			<view class="table">
				<view class="table-header">
					<view class="col-2">费用自理</view>
				</view>

				<view class="table-tr" v-for="(item, index) in tourist_self_fee_rules" :key="index">
					<view class="first-td">{{ item.sub_type_name }}</view>
					<view class="second-td">{{ format(item.display_items) }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
import { computed } from "vue"
const { expenses } = defineProps({
	expenses: {
		type: Array,
		default: () => [],
	},
})
// 获取费用包含
const tourist_include_fee_rules = computed(() => {
	return expenses.find((item) => item.type === 10).sub_type_groups
})
// 获取费用自理
const tourist_self_fee_rules = computed(() => {
	return expenses.find((item) => item.type === 20).sub_type_groups
})

const format = (list: any[]) => {
	return list.join(";")
}
</script>

<style lang="scss" scoped>
.card-title {
	margin-bottom: 24rpx;
	font-weight: 600;
	font-size: 36rpx;
	color: rgba(0, 0, 0, 0.9);
	line-height: 52rpx;
}

.card {
	padding: 32rpx 24rpx;
	margin-bottom: 16rpx;
	border-radius: 16rpx;
	background-color: #fff;
}

.refund-rule {
	.card-title {
		margin-bottom: 32rpx;
	}

	.refund-type {
		position: relative;
		padding-left: 18rpx;
		font-weight: 500;
		font-size: 28rpx;
		color: #1d2129;
		line-height: 40rpx;

		&::before {
			content: "";
			position: absolute;
			left: 0;
			top: 50%;
			transform: translateY(-50%);
			width: 6rpx;
			height: 24rpx;
			background: #fee038;
			border-radius: 4rpx;
		}
	}

	.tip-text {
		font-size: 28rpx;
		color: #4e5969;
		line-height: 40rpx;
	}

	.table {
		overflow: hidden;
		margin-top: 24rpx;
		border-radius: 16rpx;
		border: 1rpx solid #e9eaee;

		.table-header {
			display: flex;
			align-items: center;
			background-color: #f8f8f9;
			font-size: 24rpx;
			color: #86909c !important;
			line-height: 34rpx !important;
		}

		.table-tr {
			display: flex;
			align-items: stretch;
			border-top: 1rpx solid #e9eaee;
			color: #1d2129;
			line-height: 36rpx;
		}
	}

	.tourist-refund {
		&.tourist-refund-box {
			padding-bottom: 40rpx;
			margin-bottom: 40rpx;
			border-bottom: 1rpx solid #e5e6eb;
		}

		.first-td {
			display: flex;
			align-items: center;
			width: 160rpx;
			padding: 22rpx 28rpx;
			border-right: 1rpx solid #e9eaee;
		}

		.second-td {
			display: flex;
			align-items: center;
			padding-left: 22rpx;
			flex: 1;
		}
		.col-2 {
			width: 100%;
			padding: 22rpx 28rpx;
			text-align: center;
		}
		.tip-text {
			margin-top: 32rpx;
		}
	}

	.ta-refund {
		.refund-type {
			margin-bottom: 16rpx;
		}

		.tip-text {
			margin-top: 32rpx;

			&.no-margin {
				margin-top: 0;
			}
		}

		.first-td {
			display: flex;
			align-items: center;
			width: 402rpx;
			padding: 22rpx 28rpx;
			border-right: 1rpx solid #e9eaee;
		}

		.second-td {
			display: flex;
			align-items: center;
			flex: 1;
			text-align: center;
		}
	}
}
</style>
